package com.health.controller;


import com.health.pojo.Product;
import com.health.pojo.User;
import com.health.remote.ProductRemote;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class OrderController {

    @Resource
    private ProductRemote productRemote;

    /**
     * 传递对象参数-不需序列化,使用jackson序列化
     */
    @GetMapping("/findOrder2")
    public Product findOrder2(){
        //查询的商品id
        Integer id=10022;
        User user = new User(101, "尼古拉斯", 23);
        //调用远程服务
        Product product = productRemote.getProductById2(id, user);
        System.out.println("order服务发起对product服务调用>>");
        return product;
    }

    /**
     * 传递普通参数
     */
    @GetMapping("/findOrder")
    public String findOrder(){
        //查询的商品id
        Integer id=10011;
        //调用远程服务
        String productById = productRemote.getProductById(id);
        System.out.println("order服务发起对product服务调用>>");
        return productById;
    }
}
